#include <iostream>
#include <assert.h>
#include <math.h>
using namespace std;

class special_int
{
    public:
        special_int():sign(0),value(0){};  //Default Constructor
        special_int(int);  //Conversion Constructor
        special_int(int, int);  //Overloaded Constructor
        special_int(const special_int&);  //Copy Constructor
        //~special_int();  //Destructor
        friend special_int operator+(special_int, special_int);  //Operator + overload friend to access objects outside the class they were declared in
        friend special_int operator-(special_int, special_int);  //Operator - overload same as +
        void print() const {cout << "(" << value << "," << sign << ")" << endl;};
    private:
        int sign, value;
};

special_int operator+(special_int param, special_int param2)
{
    return param.value + param2.value;  //Invokes conversion constructor to convert from int to special_int
}

special_int operator-(special_int param, special_int param2)
{
    return param.value - param2.value;  //Same as adding
}

//Copy Constructor
special_int::special_int(const special_int& v)
{
    static int count = 0;  //Only declared/initialized once
    sign = v.sign;
    value = v.value;
    count++;
    cout << count << endl;
}

//Conversion Constructor
special_int::special_int(int a)
{
    value = a;
    if(a < 0)
        sign = -1;
    else if(a > 0)
        sign = 1;
    else
        sign = 0;
}

//Normal Constructor
special_int::special_int(int a, int b)
{
    value = a;
    if(a > 0)
        assert(b == 1);
    else if(a < 0)
        assert(b == -1);
    else
        assert(b == 0);
}

int main()
{
    special_int a(20);
    a.print();
    special_int b = a;
    special_int c(b);
    special_int* f;
    f = &c;
    special_int g = *f;
    b.print();
    g.print();
    special_int w(-30);
    special_int x = w + a;
    x.print();
    x = a - w;
    x.print();
}

/*
(20,1)
1
2
3
(20,1)
(20,1)
4
5
(-10,-1)
6
7
(50,1)

Process returned 0 (0x0)   execution time : 0.076 s
Press any key to continue.
*/
